package admin.forms;

import helpers.StringHelper;

import java.util.TreeMap;

import javax.servlet.http.HttpServletRequest;

import entities.SubmitSite;


public class SubmitSiteForm {
	public static TreeMap<String, Object> checkValid(HttpServletRequest request, SubmitSite submitSite) {
		TreeMap<String, Object> form = new TreeMap<String, Object>();
		TreeMap<String, String> check = new TreeMap<String, String>();
		
		String siteUrl = (String) request.getParameter("siteUrl");
		String sl = (String) request.getParameter("sl");
		String tl = (String) request.getParameter("tl");
		
		if (siteUrl == null || siteUrl.isEmpty()) {
			check.put("siteUrl", "Site Url is not null.");
			submitSite.setSiteUrl("");
		} else {
			submitSite.setSiteUrl(siteUrl);
		}
		
		if (sl != null) {
			submitSite.setSl(sl);
		}
		
		if (tl != null) {
			submitSite.setTl(tl);
		}
		
		
		form.put("checkValid", check);
		form.put("submitSite", submitSite);
		
		return form;
	}
}
